// 路由文件
import { createRouter, createWebHistory } from "vue-router";

import Home from '../views/Home.vue'
import UserAuth from "../components/UserAuth.vue";
import Register from "../components/Register.vue";
import HomePage from "../components/HomePage.vue";

const routes = [
    
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    {
        path: '/',
        name: 'Login',
        component: UserAuth,
    },
    {
        path: '/register',
        name: 'Register',  
        component: Register,
    },
    {
        path: '/homePage',
        name: 'HomePage',  
        component: HomePage,
    }
]

const router = createRouter({
    history: createWebHistory(),
    routes
})


router.beforeEach((to,from)=>{
    // if(to.meta.requireAuth) {
    //     let token = localStorage.getItem('auth-system-token');
    //     let isLogin = localStorage.getItem('auth-system-login');
    //     if(!token||!isLogin){
    //         return {
    //             path: '/login'
    //         }
    //     }
    // }
})

export default router;
